const cookie = {
  //设置cookie
setCookie(key,val,ops={}){
  let exp = '';
  let d = new Date();
  if(ops.expires){
    d.setDate(d.getDate() + ops.expires)
    exp = `;expires=${d}`
  }
  document.cookie = `${key}=${val}${ops.path?';path='+ops.path:''}${exp}`
},
//删除cookie
removeCookie(val,path=''){
  this.setCookie(val,'',{expires:-1,path})
},
//获取cookie的值
getCookie(key){
  let r='';
  document.cookie.split('; ').some(val=>{
      return r = val.split('=')[0] === key?val.split('=')[1]:''
  })
  return r?r:null;
},
}
export { cookie}